public class MotherUnicorn extends Thread
{
	
	
	public MotherUnicorn() 
	{
		this.start();
	}
	

	public void run()
	{
		try 
		{
			feedingBabies();
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
	}
	
	public synchronized void feedingBabies() throws InterruptedException 
	{
		while(true)
		{
			Activities.sleepyMummy.acquire();
			if(Activities.getNumberOfMeals() == 0)
			{
					System.exit(0);
			}
			else
			{
				System.out.println("Searching for food");
//				Activities.setFullPots(Activities.getNumberOfPots());
				//System.out.println("number Of Pots"+Activities.getNumberOfPots());
				//System.out.println("number Of full Pots"+Activities.getFullPots());
				//System.out.println("Mummy: 2ana bamla 2l pots");
				this.wait(3000);
				int numberOfmeals = Activities.getNumberOfMeals();
				numberOfmeals--;
				Activities.setNumberOfMeals(numberOfmeals);
				Activities.setFullPots(Activities.getNumberOfPots());
				
				System.out.println("Pots are full now");
			    
				for (int i = 0; i < Activities.getHungry().size(); i++)
				{
					System.out.println("Waking up any sleeping and hungry unicorns");
					Activities.getWaitingToEat().release();
					System.out.println("left release");
				}
			}
		}
	}	
}
